﻿$(function(){//延迟加载
	var failuretype=$('#failuretype').val();
	var failuretypeId=$('#failuretypeId').val();
	$('#addfailure').propertygrid({
		width:'310px',
		data:{"total":8,"rows":[    
		    	                  {'name':'所属故障类别','value':failuretype,'group':'ID Settings','editor':{
		    	                	  'editable':false
		    	                  }},
		    	                  {"name":"故障名称","group":"ID Settings","editor":{    
		    	                      "type":"validatebox",    
		    	                      "options":{    
		    	                      "required":true   
		    	                     }    
		    	                  }},
		    	                  {"name":"故障描述","group":"ID Settings","editor":{    
		    	                      "type":"validatebox"
		    	                  }},		    
		    	                  {"name":"故障设备归属","group":"ID Settings","editor":{
		    	                	  type:'combobox',
		    	                	  options:{
		  								valueField:'dvbelong',
		  								textField:'devresname',
		  								method:'get',
		  								url:'showalldevres',
		  								required:true,
		  								multiple:true
		  							}
		    	                  }}
		    	              ]},
		columns:[[
		         {'field':'name','title':'新故障名','width':'120px'},
		         {'field':'value','title':'','width':'170px'}		          		          
		          ]],
		//showHeader:false		    	              
	});
	
	$('#addfailurecompl').linkbutton({
		plain:true,
		iconCls:'icon-ok',
		onClick:function(){
			var failurename=$('#addfailure').propertygrid('getRows')[1].value;
			var describe=$('#addfailure').propertygrid('getRows')[2].value;
			var dvbelongs=$('#addfailure').propertygrid('getRows')[3].value;
			$.ajax({
				url:'addfailure',
				type:'POST',
				data:{
					failuretype:failuretype,
					failuretypeId:failuretypeId,
					failurename:failurename,
					dvbelongs:dvbelongs,
					describe:describe
					//rolename:rolename
				},				
				success:function(data){
					alert(data.msg);
				}
			});
		}
	});
	
})